{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1a270f36",
   "metadata": {},
   "source": [
    "## Testing an Electron\n",
    "\n",
    "You can execute an electron in a single-task workflow by simply adding a lattice decorator to the function. This technique is useful for testing and debugging individual workflow tasks in a controlled manner.\n",
    "\n",
    "### Prerequisites\n",
    "\n",
    "Write an electron that you want to test individually."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "daaf14b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import covalent as ct\n",
    "\n",
    "@ct.electron\n",
    "def add(x, y):\n",
    "   return x + y\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d044b04b",
   "metadata": {},
   "source": [
    "### Procedure\n",
    "\n",
    "Attach the `@lattice` decorator to the electron."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e0a9529e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import covalent as ct\n",
    "\n",
    "@ct.lattice\n",
    "@ct.electron\n",
    "def add(x, y):\n",
    "   return x + y"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96e80c0b",
   "metadata": {},
   "source": [
    "![Single Electron Lattice](./images/single_electron_lattice.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "afa4dd38",
   "metadata": {},
   "source": [
    "**Note**: Don’t confuse `ct.electron(lattice)`, which creates a sublattice, with `ct.lattice(electron)`, which is a workflow consisting of a single task.\n",
    "\n",
    "### See Also\n",
    "\n",
    "[Constructing an Electron](./construct_electron.ipynb)\n",
    "\n",
    "[Constructing a Lattice](./construct_lattice.ipynb)\n",
    "\n",
    "[Adding Electrons to Lattices](./add_electron_to_lattice.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
